import java.io.*;
import java.util.*;

public class TaskJ extends Thread {
    public TaskJ() {
        try {
            this.input = new BufferedReader(new FileReader("input.txt"));
            this.output = new PrintWriter("output.txt");
            this.setPriority(Thread.MAX_PRIORITY);
        } catch (Exception e) {
            System.exit(666);
        }
    }

    boolean solveSystem(int n, int modulo) {
        int m = solver[modulo][0].length - 1;
        int[] where = new int[m];
        Arrays.fill(where, -1);

        for (int col = 0, row = 0; col < m && row < n; ++col) {
            int sel = row;
            for (int i = row; i < n; ++i) {
                if (solver[modulo][i][col] > solver[modulo][sel][col]) {
                    sel = i;
                }
            }
            if (solver[modulo][sel][col] == 0) {
                continue;
            }
            for (int i = col; i <= m; ++i) {
                int temp = solver[modulo][sel][i];
                solver[modulo][sel][i] = solver[modulo][row][i];
                solver[modulo][row][i] = temp;
            }
            where[col] = row;

            for (int i = 0; i < n; ++i)
                if (i != row && solver[modulo][i][col] != 0) {
                    int c = (solver[modulo][i][col] * reverse[modulo][solver[modulo][row][col]]) % modules[modulo];
                    for (int j = col; j <= m; ++j) {
                        solver[modulo][i][j] -= (solver[modulo][row][j] * c) % modules[modulo];
                        solver[modulo][i][j] = (solver[modulo][i][j] % modules[modulo] + modules[modulo]) % modules[modulo];
                    }
                }
            ++row;
        }
        Arrays.fill(solution[modulo], 0);
        for (int i = 0; i < m; ++i)
            if (where[i] != -1)
                solution[modulo][i] = (solver[modulo][where[i]][m] * reverse[modulo][solver[modulo][where[i]][i]])  % modules[modulo];
        for (int i = 0; i < n; ++i) {
            int sum = 0;
            for (int j = 0; j < m; ++j)
                sum = (sum + solution[modulo][j] * solver[modulo][i][j]  % modules[modulo])  % modules[modulo];
            if (sum != solver[modulo][i][m])
                return false;
        }
        return true;
    }


    private void solve() throws Throwable {
        int n = nextInt();
        solver = new int[2][6][n + 1];
        two = new int[6][n + 1];
        five = new int[6][n + 1];
        solution = new int[2][n];
        int[] numbers = new int[n];
        for (int i = 0; i < n; ++i) {
            int current = nextInt();
            numbers[i] = current;
            for (int where = 5; where >= 0; --where) {
                int remainder = current % 10;
                two[where][i] = remainder % 2;
                five[where][i] = remainder % 5;
                current /= 10;
            }
        }
        int[] ans = new int[n];
        for (int row = 0; row < 6; ++row) {
            boolean satisfies = false;
            for (int wanted = 9; wanted >= 0 && !satisfies; --wanted) {
                int nowTwo = wanted % 2, nowFive = wanted % 5;
                two[row][n] = nowTwo;
                five[row][n] = nowFive;
                for (int begin = 0; begin <= row; ++begin) {
                    System.arraycopy(two[begin], 0, solver[0][begin], 0, n + 1);
                    System.arraycopy(five[begin], 0, solver[1][begin], 0, n + 1);
                }
                if (solveSystem(row + 1, 0) && solveSystem(row + 1, 1)) {
                    satisfies = true;
                }
            }
        }
        int result = 0;
        for (int where = 0; where < 6; ++where) {
            result = result * 10 + relax[five[where][n]][two[where][n]];
        }
        int count = 0;
        for (int i = 0; i < n; ++i) {
            ans[i] = relax[solution[1][i]][solution[0][i]];
            count += ans[i];
        }
        output.println(result);
        assert(count <= 108);
        output.println(count);
        for (int i = 0; i < n; ++i) {
            for (int cnt = 0; cnt < ans[i]; ++cnt) {
                output.print(numbers[i] + " ");
            }
        }
    }


    public void run() {
        try {
            solve();
        } catch (Throwable e) {
            System.err.println(e.getMessage());
            e.printStackTrace();
            System.exit(666);
        } finally {
            output.flush();
            output.close();
        }
    }

    public static void main(String[] args) {
        new TaskJ().start();
    }

    private int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    private long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    private double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    private String nextToken() throws IOException {
        while (tokens == null || !tokens.hasMoreTokens()) {
            tokens = new StringTokenizer(input.readLine());
        }
        return tokens.nextToken();
    }

    static int[][] two;
    static int[][] five;
    static int[][][] solver;
    static int []modules = {2, 5};
    static int  [][]solution;

    static int[][] reverse = {{Integer.MAX_VALUE, 1}, {Integer.MAX_VALUE, 1, 3, 2, 4}};
    static int[][] relax = new int[5][2];

    static {
        relax[0][0] = 0;
        relax[0][1] = 5;
        relax[1][0] = 6;
        relax[1][1] = 1;
        relax[2][0] = 2;
        relax[2][1] = 7;
        relax[3][0] = 8;
        relax[3][1] = 3;
        relax[4][0] = 4;
        relax[4][1] = 9;
    }


    private BufferedReader input;
    private PrintWriter output;
    private StringTokenizer tokens = null;
}